package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.EmallproductDAO;
import com.chanyachting.emall.domain.Emallproduct;
import com.chanyachting.emall.service.EmallproductService;

public class EmallproductServiceImpl implements EmallproductService {
	
	private EmallproductDAO epDao;

	public EmallproductServiceImpl() {
		
		this.epDao=new EmallproductDAO();
	}

	public boolean createEmallproduct(Emallproduct ep) {
		
		this.epDao.save(ep);
		
		return true;
	}

	public List<Emallproduct> getAllEmallproduct() {
		
		return this.epDao.find("from Emallproduct");
	}

	public List<Emallproduct> getAllPublishEmallproduct() {
		
		return this.epDao.find("from Emallproduct where status='01'");
	}

	public List<Emallproduct> getAllStopEmallproduct() {
		
		return this.epDao.find("from Emallproduct where status='00'");
	}

	public Emallproduct getOneEmallproduct(Emallproduct ep) {
		
		return (Emallproduct) this.epDao.load(Emallproduct.class, ep.getId());
		
	}

	public boolean publishEmallproduct(Emallproduct ep) {
		
		ep.setStatus("01");
		
		this.epDao.update(ep);
		
		return true;
		
	}

	public boolean stopEmallproduct(Emallproduct ep) {
		
		ep.setStatus("00");
		
		this.epDao.update(ep);
		
		return true;
	}

	public boolean updateEmallproduct(Emallproduct ep) {
		
		this.epDao.update(ep);
		
		return true;
		
		
	}

}
